<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
        layout(false);
        $this->display();
    }
    public function login(){
    	$users=M('users');
        // $data['age']=18;
    	$data['mail']=$_POST['email'];
    	$data['password']=$_POST['password'];
    	$result=$users->where($data)->select();
    	if(count($result)>0){
            // echo $result[0]['id'];
            // 设置登录状态
            cookie('userid',$result[0]['id'],3600);
    		$this->success('登录成功', U('Index/index'));
    	}else{
    		$this->error('登录失败');
    	}
    }
    public function logout(){
        // 清除登录状态
        cookie('userid',null);
        $this->success('退出成功', U('Login/index'));
    }
}